/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "CANCELACION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cancelacion.findAll", query = "SELECT c FROM Cancelacion c"),
    @NamedQuery(name = "Cancelacion.findByCcCod", query = "SELECT c FROM Cancelacion c WHERE c.cancelacionPK.ccCod = :ccCod"),
    @NamedQuery(name = "Cancelacion.findByIeCod", query = "SELECT c FROM Cancelacion c WHERE c.cancelacionPK.ieCod = :ieCod"),
    @NamedQuery(name = "Cancelacion.findByCanMonto", query = "SELECT c FROM Cancelacion c WHERE c.canMonto = :canMonto")})
public class Cancelacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CancelacionPK cancelacionPK;
    @Basic(optional = false)
    @Column(name = "CAN_MONTO")
    private double canMonto;
    @JoinColumn(name = "CC_COD", referencedColumnName = "CC_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Provision provision;
    @JoinColumn(name = "IE_COD", referencedColumnName = "IE_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private IngresoEgreso ingresoEgreso;

    public Cancelacion() {
    }

    public Cancelacion(CancelacionPK cancelacionPK) {
        this.cancelacionPK = cancelacionPK;
    }

    public Cancelacion(CancelacionPK cancelacionPK, double canMonto) {
        this.cancelacionPK = cancelacionPK;
        this.canMonto = canMonto;
    }

    public Cancelacion(int ccCod, int ieCod) {
        this.cancelacionPK = new CancelacionPK(ccCod, ieCod);
    }

    public CancelacionPK getCancelacionPK() {
        return cancelacionPK;
    }

    public void setCancelacionPK(CancelacionPK cancelacionPK) {
        this.cancelacionPK = cancelacionPK;
    }

    public double getCanMonto() {
        return canMonto;
    }

    public void setCanMonto(double canMonto) {
        this.canMonto = canMonto;
    }

    public Provision getProvision() {
        return provision;
    }

    public void setProvision(Provision provision) {
        this.provision = provision;
    }

    public IngresoEgreso getIngresoEgreso() {
        return ingresoEgreso;
    }

    public void setIngresoEgreso(IngresoEgreso ingresoEgreso) {
        this.ingresoEgreso = ingresoEgreso;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cancelacionPK != null ? cancelacionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cancelacion)) {
            return false;
        }
        Cancelacion other = (Cancelacion) object;
        if ((this.cancelacionPK == null && other.cancelacionPK != null) || (this.cancelacionPK != null && !this.cancelacionPK.equals(other.cancelacionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Cancelacion[ cancelacionPK=" + cancelacionPK + " ]";
    }
    
}
